#include <iostream>
#include <vector>
using namespace std;

class Solution
{
public:
    bool canJump(vector<int> &nums)
    {
        nums[nums.size() - 1] = -1;
        for (int i = nums.size() - 2; i >= 0; i--)
        {
            for (int index = i + 1; index <= i + nums[i]; index++)
            {
                if (nums[index] == -1)
                {
                    nums[i] = -1;
                    break;
                }
            }
        }
        return nums[0] == -1;
    }
};

int main()
{
    cout << "Code55" << endl;
    Solution s;
    // std::vector<int> nums = {2, 3, 1, 1, 4};
    std::vector<int> nums = {3, 2, 1, 0, 4};
    cout << s.canJump(nums) << endl;
    return 0;
}